package com.spring.aop.aspectj;

import com.spring.aop.Pointcut;
import com.spring.aop.PointcutAdvisor;
import lombok.Getter;
import org.aopalliance.aop.Advice;

/**
 * @Description: This is a sample class.
 * @Author: Simon
 */
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {

    private AspectJExpressionPointcut pointcut;

    private Advice advice;

    @Getter
    private String expression;

    public void setExpression(String expression) {
        this.expression = expression;
        pointcut=new AspectJExpressionPointcut(expression);
    }

    @Override
    public Advice getAdvice() {
        return advice;
    }

    @Override
    public Pointcut getPointcut() {
        if (pointcut==null){
            pointcut=new AspectJExpressionPointcut(expression);
        }
        return pointcut;
    }

    public void setAdvice(Advice advice){
        this.advice=advice;
    }
}
